package com.yztc.yidoutang.activity.darenshow_activity;

import com.yztc.yidoutang.bean.DaRenShowBean;
import com.yztc.yidoutang.bean.DaRenShowListBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2016/10/19.
 */

public class DaRenShowPresenter implements DaRenShowContract.Presenter {
    private DaRenShowContract.Model model;
    private DaRenShowContract.View view;
    private Map<String,String> map;
    private List<DaRenShowListBean> allList=new ArrayList<>();

    public DaRenShowPresenter(DaRenShowContract.View view) {
        this.view = view;
        this.model=new DaRenShowModel();
    }

    @Override
    public void getDataForNet(String page, String type) {
        map=new HashMap<>();
        //recommend_tag=0&type=90&page=1&last_tid=0&banner=0
        map.put("recommend_tag","0");
        map.put("type",type);
        map.put("page",page);
        map.put("last_tid","0");
        map.put("banner","0");
        if ((Integer.parseInt(page))==1){
            allList.clear();
        }
        model.getDaRenData(map, new DaRenShowContract.OnLoadDaRenShowListener() {
            @Override
            public void onSuccess(DaRenShowBean daRenShowBean) {
                List<DaRenShowListBean> list=daRenShowBean.getData().getGuides();
                allList.addAll(list);
                view.onDaRenSuccess(list);
            }

            @Override
            public void onFail(Exception e) {

            }
        });
    }
}
